home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_7_6.arc / MSDOS.ASM < prev    next >
Assembly Source File  |  1989-08-30  |  1KB  |  80 lines

  1. ;
  2. ; put these routines into individual library modules
  3. ;
  4.     .model    small
  5.     .code
  6.     public    exit_program,ms_dos,outchr,outchr_newline,outchr_unsigned
  7.  
  8. ;;    exit program
  9. ;
  10. exit_program proc
  11.     mov    ax,4C00h
  12.     jmp    ms_dos
  13. exit_program endp
  14.  
  15.  
  16. ;;    ms dos
  17. ;
  18. ms_dos    proc
  19.     int    21h
  20.     ret
  21. ms_dos    endp
  22.  
  23.  
  24. ;;    outchr
  25. ;
  26. ;    entry    AL    character
  27. ;    uses    AX
  28. ;
  29. outchr    proc
  30.     push    dx
  31.     mov    ah,2
  32.     mov    dl,al
  33.     call    ms_dos
  34.     pop    dx
  35.     ret
  36. outchr    endp
  37.  
  38.  
  39. ;;    outchr newline
  40. ;
  41. ;    uses    AX
  42. ;
  43. outchr_newline proc
  44.     mov    al,'M'-'@'
  45.     call    outchr
  46.     mov    al,'J'-'@'
  47.     jmp    outchr
  48. outchr_newline endp
  49.  
  50.  
  51. ;;    outchr unsigned
  52. ;
  53. ;    entry    AX    number
  54. ;    uses    AX
  55. ;
  56. outchr_unsigned proc
  57.     push    cx
  58.     push    dx
  59.  
  60.     mov    cx,10
  61.     mov    dx,-1            ; push sentinal
  62. ocu1:    push    dx
  63.     xor    dx,dx
  64.     div    cx            ; divide & push decimal digits
  65.     and    ax,ax
  66.     jnz    ocu1
  67.     inc    dx
  68. ocu2:    xchg    ax,dx            ; pop & display digits
  69.     add    al,'0'-1
  70.     call    outchr
  71.     pop    dx
  72.     inc    dx
  73.     jnz    ocu2            ;  if not sentinal
  74.     pop    dx
  75.     pop    cx
  76.     ret
  77. outchr_unsigned endp
  78.  
  79.     end
  80.